import { Injectable } from '@angular/core';
import * as gc from 'src/app/global/globalconst';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';

const pre = '/push'

export class DailyAggregation{
  billdate:string;bp:string;cp:string;
  bp_pairs:number;bp_kilo:number;
  cp_pairs:number;cp_kilo:number;
}

@Injectable({
  providedIn: 'root'
})
export class DailyaggregationService {

  url = {
    'getAggregation' : gc.server + '/' + pre + '/getDailyAggregation'
  }

  constructor(
    private http:HttpClient
  ) { 
    
  }


  /**
   * 单个染厂的白坯入库单、成品发货单，按照天统计
   * @param sdate 查询数据的起始日期
   * @param edate 查询数据的终止日期
   * @param mill 指定染厂 - 只获取单个染厂的数据
   */
  getAggregation(sdate:string,edate:string,mill:string):Observable<DailyAggregation[]>{
    const url = this.url.getAggregation + `/${sdate}/${edate}/${mill}`;
    console.log('获取日报表数据的请求是：' + url);
    return this.http.get<DailyAggregation[]>(url);
  }
}
